mudbox::Texture Class Reference

#include <material.h>

Inheritance diagram for mudbox::Texture:

Inheritance graph
[legend]
List of all members.

Detailed Description

Represents a texture tile inside a texture pool.

Textures are like images (see the Image class) in that they are a 2d array of pixel values. Like images, Textures support many formats. Textures can also be used internally as the target of OpenGL rendering operations -- that is, Mudbox scenes can be rendered into Textures. Textures have the ability to keep old versions of themselves around for undo/redo purposes.


Public Member Functions

virtual const mudbox::ClassDesc RuntimeClass (void) const
virtual void  Create (unsigned int iWidth, unsigned int iHeight, unsigned int iChannelCount, enum Image::Format eFormat, const Color &cColor)
  Create/allocate the content of the texture.
virtual void  Create (unsigned int iWidth, unsigned int iHeight, unsigned int iChannelCount, enum Image::Format eFormat)
  Create/allocate the content of the texture.
virtual bool  CreateFromFile (const QString &sFileName)
  Create the texture from an image file.
virtual void  CopyTo (Texture &cTexture) const
  Copy the content of the texture into another one, using the current opengl pipeline settings.
virtual unsigned int  Width (void) const
  Returns the width of the texture in pixels.
virtual unsigned int  Height (void) const
  Returns the height of the texture in pixels.
virtual unsigned int  BitDepth (void) const
  Returns the bit depth of the texture (per channel).
virtual enum Image::Format  Format (void) const
  Returns the format of the texture.
virtual bool  Activate (void) const
  Binds the texture node.
virtual bool  Deactivate (void) const
  UnBinds the texture node, but does not restore the previous active texture.
virtual unsigned int  OpenGLName (void) const
  Returns the opengl name of the texture.
virtual bool  SetAsRenderTarget (void)
  Sets the texture as a render target. Subsequent renderings will render into that texture.
virtual bool  RestoreRenderTarget (void)
  Restore previous render target.
virtual abool getFilteringPref ()
virtual void  CopyFrom (Image *pImage)
  Create the texture content from an image.
virtual void  ReplaceWith (Image *pImage)
  Replace the texture with the content from an image.
virtual void  CopyTo (Image *pImage, bool tiled=true, const ImgTile *region=0, ImageDescriptor::MemoryChannelOrder eOrder=ImageDescriptor::orderRGBA)
  Copy the texture or a region thereof to an image. If region == 0, it copies the entire texture.
virtual void  SetLocation (unsigned int iLocation)
  Sets the location for the texture pool.
virtual unsigned int  Location (void)
  Gets the location for the texture pool.
virtual int64  TotalMemoryUsage (void) const
  Return the memory usage of all texture instances of the class in bytes.
virtual void  SetLive (bool bLive)
  For internal use only.
virtual bool  IsLive (void) const
  For internal use only.
virtual void  SetFiltered (bool bFiltered)
  Set the texture filtering on this texture.
virtual void  SetConvert32To16bitFloat (bool bConvert)
  Set to true to automatically convert 32 bit floating point textures to 16 bit floating point textures on the gpu.
Undo Mechanism
These methods provide a multi-level undo and redo system for textures.

virtual bool  NewVersion ()
  Caches a copy of the current texture. Returns true if successful.
virtual bool  PrevVersion ()
  Makes the previous version of the texture current. Returns true if successful.
virtual bool  NextVersion ()
  Makes the 'next' version of the texture current. Returns true if successful.
virtual int  NumVersions ()
  Returns the number of versions of this texture. Returns 1 for unversioned textures.
virtual bool  MergeOldestVersions ()
  Merges the oldest two versions of this texture. Returns true if successful.
virtual bool  PurgeNewerVersions ()
  Purges any versions of this texture after the current one (i.e. all "next" versions). Returns true if successful.
virtual bool  PurgeAllButCurrentVersion ()
  Purges all but the current version of this Texture. Used to flush the undo queue. Returns true if successful.
virtual bool  BeginUndoableOperation ()
  Notifies the texture that you are about to start making undoable changes to it (such as a brush stroke). Returns true if successful.
virtual bool  EndUndoableOperation ()
  Notifies the texture that you have finished making undoable changes to it (such as a brush stroke). Returns true if successful.
Dirty Tile Methods
The dirty tile methods are used by the undo mechanism so that it only has to save those portions of the texture that has been modified.

void  ResetDirtyTile ()
  Resets the dirty region to be empty.
virtual void  AddToDirtyTile (int x, int y)
  Notifies the texture that part of it has changed.
virtual void  AddToDirtyTile (const ImgTile &t)
  Notifies the texture that part of it has changed.
const ImgTile DirtyTile () const
  Returns the dirty rectangle of the texture.

Static Public Member Functions

const mudbox::ClassDesc StaticClass (void)
mudbox::Node CreateInstances (unsigned int iCount=1)

Protected Member Functions

  Texture (void)
  Constructor. Do not use it directly; Use CreateInstance() instead.

Protected Attributes

ImgTile  m_DirtyTile

Constructor & Destructor Documentation

mudbox::Texture::Texture void   )  [protected]
 

Constructor. Do not use it directly; Use CreateInstance() instead.

            Texture *myTexture = CreateInstance<Texture>();

Member Function Documentation

virtual const mudbox::ClassDesc* mudbox::Texture::RuntimeClass void   )  const [inline, virtual]
 

Reimplemented from mudbox::Node.

00425 :
const mudbox::ClassDesc* mudbox::Texture::StaticClass void   )  [static]
 

Reimplemented from mudbox::Node.

mudbox::Node* mudbox::Texture::CreateInstances unsigned int  iCount = 1  )  [static]
 

Reimplemented from mudbox::Node.

virtual void mudbox::Texture::Create unsigned int  iWidth,
unsigned int  iHeight,
unsigned int  iChannelCount,
enum Image::Format  eFormat,
const Color cColor
[virtual]
 

Create/allocate the content of the texture.

Parameters:
iWidth  [in] The width
iHeight  [in] The height
iChannelCount  [in] The number of channels (for example, RGBA would be 4)
eFormat  [in] The image format (see the Image class for details)
cColor  [in] The initial color that the texture should be set to
virtual void mudbox::Texture::Create unsigned int  iWidth,
unsigned int  iHeight,
unsigned int  iChannelCount,
enum Image::Format  eFormat
[virtual]
 

Create/allocate the content of the texture.

Parameters:
iWidth  [in] The width
iHeight  [in] The height
iChannelCount  [in] The number of channels (for example, RGBA would be 4)
eFormat  [in] The image format (see the Image class for details)
virtual bool mudbox::Texture::CreateFromFile const QString &  sFileName  )  [virtual]
 

Create the texture from an image file.

Parameters:
sFileName  [in] The name of the image file to be read in
virtual void mudbox::Texture::CopyTo Texture cTexture  )  const [virtual]
 

Copy the content of the texture into another one, using the current opengl pipeline settings.

Parameters:
cTexture  [in] The texture to be copied to
virtual unsigned int mudbox::Texture::Width void   )  const [virtual]
 

Returns the width of the texture in pixels.

virtual unsigned int mudbox::Texture::Height void   )  const [virtual]
 

Returns the height of the texture in pixels.

virtual unsigned int mudbox::Texture::BitDepth void   )  const [virtual]
 

Returns the bit depth of the texture (per channel).

virtual enum Image::Format mudbox::Texture::Format void   )  const [virtual]
 

Returns the format of the texture.

virtual bool mudbox::Texture::Activate void   )  const [virtual]
 

Binds the texture node.

This call makes the texture active, so that opengl operations will be able to use it. It calls glBindTexture() internally.

virtual bool mudbox::Texture::Deactivate void   )  const [virtual]
 

UnBinds the texture node, but does not restore the previous active texture.

The active opengl texture after this call is undefined.

virtual unsigned int mudbox::Texture::OpenGLName void   )  const [virtual]
 

Returns the opengl name of the texture.

virtual bool mudbox::Texture::SetAsRenderTarget void   )  [virtual]
 

Sets the texture as a render target. Subsequent renderings will render into that texture.

virtual bool mudbox::Texture::RestoreRenderTarget void   )  [virtual]
 

Restore previous render target.

virtual abool* mudbox::Texture::getFilteringPref  )  [virtual]
 
virtual void mudbox::Texture::CopyFrom Image pImage  )  [virtual]
 

Create the texture content from an image.

Parameters:
pImage  [in] the Image to copy the texture from
virtual void mudbox::Texture::ReplaceWith Image pImage  )  [virtual]
 

Replace the texture with the content from an image.

Parameters:
pImage  [in] the Image to copy the texture from
virtual void mudbox::Texture::CopyTo Image pImage,
bool  tiled = true,
const ImgTile region = 0,
ImageDescriptor::MemoryChannelOrder  eOrder = ImageDescriptor::orderRGBA
[virtual]
 

Copy the texture or a region thereof to an image. If region == 0, it copies the entire texture.

Parameters:
pImage  [in] A pointer to the image target
tiled  [in] Set to true if this is a tiled image
region  [in] Specifies a region to copy (see the ImgTile class)
eOrder  [in] Specify what order you want the color channels stored
virtual void mudbox::Texture::SetLocation unsigned int  iLocation  )  [virtual]
 

Sets the location for the texture pool.

Parameters:
iLocation  [in] Location can be one of TexturePool::locationGPU, TexturePool::locationCPU, or TexturePool::locationDisk
virtual unsigned int mudbox::Texture::Location void   )  [virtual]
 

Gets the location for the texture pool.

Possible values are TexturePool::locationUnknown, TexturePool::locationGPU, TexturePool::locationCPU, or TexturePool::locationDisk

virtual int64 mudbox::Texture::TotalMemoryUsage void   )  const [virtual]
 

Return the memory usage of all texture instances of the class in bytes.

virtual void mudbox::Texture::SetLive bool  bLive  )  [virtual]
 

For internal use only.

virtual bool mudbox::Texture::IsLive void   )  const [virtual]
 

For internal use only.

virtual bool mudbox::Texture::NewVersion  )  [virtual]
 

Caches a copy of the current texture. Returns true if successful.

This is part of a Texture's built-in undo mechanism. Effectively, the current version of the texture becomes the previous version, and a fresh copy is now the current version. Any 'next' versions are purged.

virtual bool mudbox::Texture::PrevVersion  )  [virtual]
 

Makes the previous version of the texture current. Returns true if successful.

This is part of a Texture's built-in undo mechanism. The current version of the texture becomes the next version, and the previous version becomes the current version.

virtual bool mudbox::Texture::NextVersion  )  [virtual]
 

Makes the 'next' version of the texture current. Returns true if successful.

This is part of a Texture's built-in undo mechanism. The current version of the texture becomes the previous version, and the next version becomes the current version.

virtual int mudbox::Texture::NumVersions  )  [virtual]
 

Returns the number of versions of this texture. Returns 1 for unversioned textures.

virtual bool mudbox::Texture::MergeOldestVersions  )  [virtual]
 

Merges the oldest two versions of this texture. Returns true if successful.

This is used to limit the number of items on the undo queue.

virtual bool mudbox::Texture::PurgeNewerVersions  )  [virtual]
 

Purges any versions of this texture after the current one (i.e. all "next" versions). Returns true if successful.

Creating a new version will implicitly purge newer versions, but if another operation takes place that puts a new item on the undo queue, this should be called to purge newer versions of this texture.

virtual bool mudbox::Texture::PurgeAllButCurrentVersion  )  [virtual]
 

Purges all but the current version of this Texture. Used to flush the undo queue. Returns true if successful.

virtual bool mudbox::Texture::BeginUndoableOperation  )  [virtual]
 

Notifies the texture that you are about to start making undoable changes to it (such as a brush stroke). Returns true if successful.

This method calls NewVersion() internally.

virtual bool mudbox::Texture::EndUndoableOperation  )  [virtual]
 

Notifies the texture that you have finished making undoable changes to it (such as a brush stroke). Returns true if successful.

virtual void mudbox::Texture::SetFiltered bool  bFiltered  )  [virtual]
 

Set the texture filtering on this texture.

Parameters:
bFiltered  [in] true to turn filtering on, false to turn filtering off.
virtual void mudbox::Texture::SetConvert32To16bitFloat bool  bConvert  )  [virtual]
 

Set to true to automatically convert 32 bit floating point textures to 16 bit floating point textures on the gpu.

Parameters:
bConvert  [in] true to convert, false to leave 32 bit float textures as is.
void mudbox::Texture::ResetDirtyTile  )  [inline]
 

Resets the dirty region to be empty.

00611         {
00612             m_DirtyTile = ImgTile(0, 0, 0, 0);       
00613         }
virtual void mudbox::Texture::AddToDirtyTile int  x,
int  y
[inline, virtual]
 

Notifies the texture that part of it has changed.

Call this when you are modifying a texture, to indicate what part has changed.

Parameters:
x  [in] The X coordinate of the changed pixel
y  [in] The Y coordinate of the changed pixel
00622         {
00623             m_DirtyTile.ExpandToInclude(x, y);
00624         }
virtual void mudbox::Texture::AddToDirtyTile const ImgTile t  )  [inline, virtual]
 

Notifies the texture that part of it has changed.

This is used by the undo mechanism so that it only has to save those portions of the image that have been modified. Call this when you are modifying a texture.

Parameters:
t  [in] The X coordinate of the changed pixel
00634         {
00635             m_DirtyTile.ExpandToInclude(t.x, t.y);
00636             m_DirtyTile.ExpandToInclude(t.x+t.nx, t.y+t.ny);
00637         }
const ImgTile& mudbox::Texture::DirtyTile  )  const [inline]
 

Returns the dirty rectangle of the texture.

00640 { return m_DirtyTile; }

Member Data Documentation

ImgTile mudbox::Texture::m_DirtyTile [protected]
 

mudbox::Texture mudbox::Texture mudbox::Texture mudbox::Texture mudbox::Texture mudbox::Texture mudbox::Texture mudbox::Texture mudbox::Texture mudbox::Texture
mudbox::Texture mudbox::Texture mudbox::Texture mudbox::Texture mudbox::Texture mudbox::Texture mudbox::Texture mudbox::Texture mudbox::Texture mudbox::Texture